package com.sc.admin.test.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sc.admin.test.RoleEntity;
import com.sc.admin.test.mapper.RoleMapper;
import com.sc.common.service.AbstractBaseService;
import com.sc.admin.test.mapper.AdministratorsMapper;
import com.sc.admin.test.AdministratorsEntity;
import com.sc.admin.test.service.IAdministratorsService;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import com.sc.core.util.DataAutoSearch.DataAutoSearch;
import java.util.List;

/**
 * 管理员服务实现类
 */
@Primary
@Service
@AllArgsConstructor
@Log4j2
public class AdministratorsServiceImpl extends AbstractBaseService<AdministratorsMapper, AdministratorsEntity> implements IAdministratorsService {

    private final RoleMapper roleMapper;

    public List<AdministratorsEntity> getList(DataAutoSearch dataAutoSearch){
        QueryWrapper<AdministratorsEntity> objectQueryWrapper = new QueryWrapper<>();

        objectQueryWrapper.eq("cur.status", "1");
        objectQueryWrapper.eq("par.id", "1");
        objectQueryWrapper.orderBy(true , true, "cur.create_time");
        List<RoleEntity> defaultList      = roleMapper.getDefaultList(Wrappers.<RoleEntity>lambdaQuery(), "");
        Long             defaultListCount = roleMapper.getDefaultListCount(Wrappers.<RoleEntity>lambdaQuery());

        log.info("defaultList: {}", defaultList);
        log.info("defaultListCount: {}", defaultListCount);
        return baseMapper.getList(objectQueryWrapper, dataAutoSearch.builderPage());
    }
}